package pide.gui;

import java.awt.Dimension;
import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;
import java.awt.Toolkit;

import javax.swing.JFrame;

public class CenteredJFrame extends JFrame {

	
	private static final long serialVersionUID = -7595044430328736390L;

	public CenteredJFrame() throws HeadlessException {
		super();
		
	}

	public CenteredJFrame(GraphicsConfiguration gc) {
		super(gc);
		
	}

	public CenteredJFrame(String title, GraphicsConfiguration gc) {
		super(title, gc);
		
	}

	public CenteredJFrame(String title) throws HeadlessException {
		super(title);		
	}
	@Override
	public void pack() {		
		super.pack();
		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation(dim.width/2-getSize().width/2, dim.height/2-getSize().height/2);
	}
	
	@Override
	public void setSize(Dimension d) {		
		super.setSize(d);
		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation(dim.width/2-getSize().width/2, dim.height/2-getSize().height/2);
	}
	
	@Override
	public void setSize(int width, int height) {
		super.setSize(width, height);
		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation(dim.width/2-getSize().width/2, dim.height/2-getSize().height/2);
	}

}
